package yang.yu.sunny.application;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import yang.yu.sunny.domain.Product;

/**
 * 产品销售额信息
 * Created by yyang on 16/3/29.
 */
public class ProductSalesVolume {
    private Product product;
    private double amount;

    public ProductSalesVolume(Product product, double amount) {
        this.product = product;
        this.amount = amount;
    }

    public Product getProduct() {
        return product;
    }

    public double getAmount() {
        return amount;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;

        if (!(o instanceof ProductSalesVolume)) return false;

        ProductSalesVolume that = (ProductSalesVolume) o;

        return new EqualsBuilder()
                .append(getAmount(), that.getAmount())
                .append(getProduct(), that.getProduct())
                .isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37)
                .append(getProduct())
                .append(getAmount())
                .toHashCode();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("product", product)
                .append("amount", amount)
                .toString();
    }
}
